import Vue from "vue";
import Vuex from "vuex";
import {Message} from "element-ui";
import router from "@/router";
// import getters from "./getters"
//1、安装插件
Vue.use(Vuex);

//2、创建store对象
export default new Vuex.Store({
  state:{
    addSwitch:true,
    token:'',
    isSun:true,
    aside:false,
    number:{
      collectionNum:0,
      dynamicNum:0,
      focusNum:0
    },
    userList:{

    },
    other:{
      type:'',
      uid:'',
      userName:''
    }
  },
  mutations:{
    sunSwitch:(state)=> {
      state.isSun = !state.isSun;
    },
    asideSwitch:(state)=>{
      state.aside=!state.aside
    },
    setUserList:(state,map)=>{    //缓存关注列表
      state.userList=map
    },
    setNumber:(state,number)=>{
      state.number=number
    },
    setOther:(state,user)=>{
      state.other=user
    },
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    CLEAN_TOKEN:(state)=>{
      state.token=null
      localStorage.removeItem("TOKEN")
      Message.success("已退出登录~~")
      router.push("/main")
    }

  },
  // getters,
  actions: {},

});

